package edu.gyc.hiwxm.exception;

import lombok.extern.slf4j.Slf4j;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@ControllerAdvice
@Slf4j
public class GlobalDefultExceptionHandler {

    //声明要捕获的异常
    @ExceptionHandler(Exception.class)

    public String defultExcepitonHandler(HttpServletRequest request, Exception e, Model model) {
        e.printStackTrace();
        model.addAttribute("error", e.getMessage());
	return "error";
    }
}
